<?
require("includes.php");

db_prepare($db_host,$db_name,$db_login,$db_password);


$rs = mysql_query("CREATE DATABASE WEBTODO;");

// GLOBAL 

$rs = mysql_query("DROP TABLE global_password;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS global_password(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Password TEXT,".
		"f_TIMESTAMP TIMESTAMP".
		");");


$rs = mysql_query("DROP TABLE global_projects;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS global_projects(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Description TEXT,".
		"f_TIMESTAMP TIMESTAMP".
		");");

$rs = mysql_query("INSERT INTO global_projects VALUES (0,'webtodo','',NULL);");
$rs = mysql_query("INSERT INTO global_projects VALUES (0,'123pcb','',NULL);");
$rs = mysql_query("INSERT INTO global_projects VALUES (0,'infoselect','',NULL);");


$rs = mysql_query("INSERT INTO global_password VALUES (0,'ADM','ubnukrul',NULL);");

// TYPES

$rs = mysql_query("DROP TABLE types_webtodo;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS types_webtodo(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Description TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT".
		");");

$rs = mysql_query("INSERT INTO types_webtodo VALUES (0,'Bug ','A bug that cannot be worked around',NULL,0);");
$rs = mysql_query("INSERT INTO types_webtodo VALUES (0,'Work ','A bug that has a Workaround',NULL,1);");
$rs = mysql_query("INSERT INTO types_webtodo VALUES (0,'Feat','Feature that can be listed in marketing material',NULL,2);");
$rs = mysql_query("INSERT INTO types_webtodo VALUES (0,'Lock ','Major bug that locks the system (crash) or can Lose data',NULL,3);");
$rs = mysql_query("INSERT INTO types_webtodo VALUES (0,'Pol','Polish - improvement that does not really add a new feature',NULL,4);");
$rs = mysql_query("INSERT INTO types_webtodo VALUES (0,'Misc','Miscellaneous',NULL,5);");


$rs = mysql_query("DROP TABLE types_123pcb;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS types_123pcb(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Description TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT".
		");");

$rs = mysql_query("INSERT INTO types_123pcb VALUES (0,'Bug ','A bug that cannot be worked around',NULL,0);");
$rs = mysql_query("INSERT INTO types_123pcb VALUES (0,'Work ','A bug that has a Workaround',NULL,1);");
$rs = mysql_query("INSERT INTO types_123pcb VALUES (0,'Feat','Feature that can be listed in marketing material',NULL,2);");
$rs = mysql_query("INSERT INTO types_123pcb VALUES (0,'Lock ','Major bug that locks the system (crash) or can Lose data',NULL,3);");
$rs = mysql_query("INSERT INTO types_123pcb VALUES (0,'Pol','Polish - improvement that does not really add a new feature',NULL,4);");
$rs = mysql_query("INSERT INTO types_123pcb VALUES (0,'Misc','Miscellaneous',NULL,5);");


$rs = mysql_query("DROP TABLE types_infoselect;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS types_infoselect(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Description TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT".
		");");

$rs = mysql_query("INSERT INTO types_infoselect VALUES (0,'Bug ','A bug that cannot be worked around',NULL,0);");
$rs = mysql_query("INSERT INTO types_infoselect VALUES (0,'Work ','A bug that has a Workaround',NULL,1);");
$rs = mysql_query("INSERT INTO types_infoselect VALUES (0,'Feat','Feature that can be listed in marketing material',NULL,2);");
$rs = mysql_query("INSERT INTO types_infoselect VALUES (0,'Lock ','Major bug that locks the system (crash) or can Lose data',NULL,3);");
$rs = mysql_query("INSERT INTO types_infoselect VALUES (0,'Pol','Polish - improvement that does not really add a new feature',NULL,4);");
$rs = mysql_query("INSERT INTO types_infoselect VALUES (0,'Misc','Miscellaneous',NULL,5);");


// Priorities

$rs = mysql_query("DROP TABLE priorities_webtodo;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS priorities_webtodo(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Description TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT".
		");");

$rs = mysql_query("INSERT INTO priorities_webtodo VALUES (0,'Urgent','Emergency that must be done immediately',NULL,0);");
$rs = mysql_query("INSERT INTO priorities_webtodo VALUES (0,'Essential','Must be done for next release',NULL,1);");
$rs = mysql_query("INSERT INTO priorities_webtodo VALUES (0,'Important','Would be nice for next release but not essential',NULL,2);");
$rs = mysql_query("INSERT INTO priorities_webtodo VALUES (0,'Low','Low priority - probably won`t be done in near future but we want to record it',NULL,3);");
$rs = mysql_query("INSERT INTO priorities_webtodo VALUES (0,'Skip','Probably will never be done but we want to record it',NULL,4);");


$rs = mysql_query("DROP TABLE priorities_123pcb;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS priorities_123pcb(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Description TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT".
		");");

$rs = mysql_query("INSERT INTO priorities_123pcb VALUES (0,'Urgent','Emergency that must be done immediately',NULL,0);");
$rs = mysql_query("INSERT INTO priorities_123pcb VALUES (0,'Essential','Must be done for next release',NULL,1);");
$rs = mysql_query("INSERT INTO priorities_123pcb VALUES (0,'Important','Would be nice for next release but not essential',NULL,2);");
$rs = mysql_query("INSERT INTO priorities_123pcb VALUES (0,'Low','Low priority - probably won`t be done in near future but we want to record it',NULL,3);");
$rs = mysql_query("INSERT INTO priorities_123pcb VALUES (0,'Skip','Probably will never be done but we want to record it',NULL,4);");


$rs = mysql_query("DROP TABLE priorities_infoselect;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS priorities_infoselect(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Name TEXT,".
		"f_Description TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT".
		");");

$rs = mysql_query("INSERT INTO priorities_infoselect VALUES (0,'Urgent','Emergency that must be done immediately',NULL,0);");
$rs = mysql_query("INSERT INTO priorities_infoselect VALUES (0,'Essential','Must be done for next release',NULL,1);");
$rs = mysql_query("INSERT INTO priorities_infoselect VALUES (0,'Important','Would be nice for next release but not essential',NULL,2);");
$rs = mysql_query("INSERT INTO priorities_infoselect VALUES (0,'Low','Low priority - probably won`t be done in near future but we want to record it',NULL,3);");
$rs = mysql_query("INSERT INTO priorities_infoselect VALUES (0,'Skip','Probably will never be done but we want to record it',NULL,4);");



// Peoples

$rs = mysql_query("DROP TABLE people_webtodo;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS people_webtodo(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Initials TEXT,".
		"f_Name TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT,".
		"f_Mail TEXT,".
		"f_Phone TEXT,".
		"f_CellPhone TEXT,".
		"f_Hrs TEXT,".
		"f_Start TEXT,".
		"f_Responsibiliites TEXT,".
		"f_Permitions TEXT,".
		"f_Password TEXT".
		");");


$rs = mysql_query("DROP TABLE people_123pcb;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS people_123pcb(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Initials TEXT,".
		"f_Name TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT,".
		"f_Mail TEXT,".
		"f_Phone TEXT,".
		"f_CellPhone TEXT,".
		"f_Hrs TEXT,".
		"f_Start TEXT,".
		"f_Responsibiliites TEXT,".
		"f_Permitions TEXT,".
		"f_Password TEXT".
		");");


$rs = mysql_query("DROP TABLE people_infoselect;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS people_infoselect(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Initials TEXT,".
		"f_Name TEXT,".
		"f_TIMESTAMP TIMESTAMP,".
		"f_Order TEXT,".
		"f_Mail TEXT,".
		"f_Phone TEXT,".
		"f_CellPhone TEXT,".
		"f_Hrs TEXT,".
		"f_Start TEXT,".
		"f_Responsibiliites TEXT,".
		"f_Permitions TEXT,".
		"f_Password TEXT".
		");");



// Tasks

$rs = mysql_query("DROP TABLE tasks_webtodo;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS tasks_webtodo(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Owner TEXT,".
		"f_Category TEXT,".
		"f_Description TEXT,".
		"f_Type TEXT,".
		"f_Priority TEXT,".
		"f_Version TEXT,".
                "f_PA1 TEXT,".
                "f_PA2 TEXT,".
                "f_Est TEXT,".
                "f_ES TEXT,".
                "f_Act TEXT,".
                "f_State TEXT,".
                "f_Notes BLOB,".
                "f_Done TEXT,".
                "f_Source TEXT,".
                "f_Entered TEXT,".
                "f_Admin TEXT,".
                "f_Tester TEXT,".
                "f_Doc TEXT,".
                "f_Menu TEXT,".
                "f_Questions TEXT,".
                "f_Answers TEXT,".
		"f_TIMESTAMP TIMESTAMP".
		");");


$rs = mysql_query("DROP TABLE tasks_123pcb;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS tasks_123pcb(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Owner TEXT,".
		"f_Category TEXT,".
		"f_Description TEXT,".
		"f_Type TEXT,".
		"f_Priority TEXT,".
		"f_Version TEXT,".
                "f_PA1 TEXT,".
                "f_PA2 TEXT,".
                "f_Est TEXT,".
                "f_ES TEXT,".
                "f_Act TEXT,".
                "f_State TEXT,".
                "f_Notes BLOB,".
                "f_Done TEXT,".
                "f_Source TEXT,".
                "f_Entered TEXT,".
                "f_Admin TEXT,".
                "f_Tester TEXT,".
                "f_Doc TEXT,".
                "f_Menu TEXT,".
                "f_Questions TEXT,".
                "f_Answers TEXT,".
		"f_TIMESTAMP TIMESTAMP".
		");");


$rs = mysql_query("DROP TABLE tasks_infoselect;");
$rs = mysql_query("CREATE TABLE IF NOT EXISTS tasks_infoselect(".
		"f_id INT AUTO_INCREMENT PRIMARY KEY,".
		"f_Owner TEXT,".
		"f_Category TEXT,".
		"f_Description TEXT,".
		"f_Type TEXT,".
		"f_Priority TEXT,".
		"f_Version TEXT,".
                "f_PA1 TEXT,".
                "f_PA2 TEXT,".
                "f_Est TEXT,".
                "f_ES TEXT,".
                "f_Act TEXT,".
                "f_State TEXT,".
                "f_Notes BLOB,".
                "f_Done TEXT,".
                "f_Source TEXT,".
                "f_Entered TEXT,".
                "f_Admin TEXT,".
                "f_Tester TEXT,".
                "f_Doc TEXT,".
                "f_Menu TEXT,".
                "f_Questions TEXT,".
                "f_Answers TEXT,".
		"f_TIMESTAMP TIMESTAMP".
		");");


$err = mysql_errno();
if($err != 0) {
	printf("%s<br>",mysql_error());
} else {
	printf("%s","OK<br>");
}

db_close();
?>